package com.whale;

import java.util.ArrayList;
import java.util.List;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

import com.whale.activity.WhaleBaseActivity;

/***
 * 附件信息 类NearbyActivity.java的实现描述：TODO 类实现描述
 * 
 * @author alibaba 2011-9-10 下午08:46:24
 */
public class NearbyActivity extends WhaleBaseActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.nearby_activity);
        ListView listView = (ListView) findViewById(R.id.nearbyListView);
        List<Shop> dataList = new ArrayList<Shop>();
        dataList.add(new Shop(1l,"星巴客（阿里巴巴园区）","5星","滨兴小区","阿里巴巴园区"));
        dataList.add(new Shop(2l,"刘老跟","5星","滨兴小区","滨兴小区"));
        dataList.add(new Shop(3l,"张三店","5星","滨兴小区","滨兴小区"));
        dataList.add(new Shop(4l,"李四店","5星","滨兴小区","滨兴小区"));
        dataList.add(new Shop(5l,"fdsfdsfds","5星","滨兴小区","滨兴小区"));
        dataList.add(new Shop(6l,"dsfs","5星","滨兴小区","滨兴小区"));
        listView.setAdapter(new NearbyListAdapter(dataList));
    }

    class NearbyListAdapter extends BaseAdapter {
        private List<Shop> dataList;
        public NearbyListAdapter(List<Shop> dataList){
            this.dataList = dataList;
        }
        public int getCount() {
            return dataList.size();
        }

        @Override
        public Object getItem(int position) {
            return dataList.get(position);
        }

        @Override
        public long getItemId(int position) {
            return dataList.get(position).id;
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            Shop shop = dataList.get(position);
            LayoutInflater inflate = LayoutInflater.from(NearbyActivity.this);
            View view = inflate.inflate(R.layout.child_list_item, null);
            ImageView shopImage = (ImageView) view.findViewById(R.id.shopImage);
            shopImage.setImageResource(R.drawable.icon);
            TextView shopName = (TextView) view.findViewById(R.id.shopName);
            shopName.setText(shop.name);
            TextView shopLevel = (TextView) view.findViewById(R.id.shopLevel);
            shopLevel.setText(shop.level);
            TextView shopInfo = (TextView) view.findViewById(R.id.shopInfo);
            shopInfo.setText(shop.info);
            return view;
        }
    }

}
